import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { TagsItem, TagsQuery, TagsForm,ProjectsQuery,ProjectsItem} from './types'
/**
 * 获取标签列表
 *
 * @param params
 */
export function getTagsList(
  params: TagsQuery
): AxiosPromise<PageResult<TagsItem[]>> {
  return request({
    url: '/tags',
    params
  })
}
export function getProjectList(
  params: ProjectsQuery
): AxiosPromise<PageResult<ProjectsItem[]>> {
  return request({
    url: '/subjects',
    params
  })
}
export function addTags(data: TagsForm) {
  console.log('添加')
  return request({
    url: '/tags',
    method: 'post',
    data:data
  })
}
export function deleteTags(id: string | number) {
  console.log('删除')
  return request({
    url: `/tags/${id}`,
    method: 'delete'
  })
}
export function updateTags(data: TagsForm) {
  console.log('数据更新')
  return request({
    url: `/tags/${data.id}`,
    method: 'put',
    data: data
  })
}
export function changeStateTags(data: { id: number; state: number }) {
  console.log('修改状态',data)
  return request({
    url: `/tags/${data.id}/${data.state}`,
    method: 'post',
  })
}